import store from '@/store'
const _import =
  process.env.NODE_ENV === 'production'
    ? file => () => import('@/views/' + file + '.vue')
    : file => require('@/views/' + file + '.vue').default

export default [
  {
    path: '404',
    component: _import('common/404'),
    name: '404',
    meta: { title: '页面不存在', isTab: true, noRecord: true },
    beforeEnter(to, from, next) {
      if (from.name === null) {
        next({ name: 'main' })
      } else {
        next()
      }
    }
  },
  {
    path: 'index',
    name: 'index',
    meta: { title: '读取用户首页', noRecord: true },
    beforeEnter(to, from, next) {
      next({ name: store.state.user.home })
    }
  },
  {
    path: 'home',
    name: 'home',
    meta: { title: '主页', noContentBox: true, noRecord: true },
    component: _import('common/home')
  },
  {
    path: 'refresh',
    component: _import('common/refresh'),
    name: 'refresh',
    meta: { title: '刷新页面', noRecord: true }
  },
  {
    path: '/noPermission',
    component: _import('common/noPermission'),
    name: 'noPermission',
    meta: { title: '无页面权限', isTab: true, noRecord: true },
    beforeEnter(to, from, next) {
      if (from.name === null) {
        next({ name: 'main' })
      } else {
        next()
      }
    }
  }
]
